/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kpsmart.model.routes;

/**
 * Route tuple is a class to represent a route as three tuple. This is needed
 * for displaying information about all routes from A to B with priority C.
 *
 * @author Oliver Behncke
 */
public class RouteTuple {

    private String from;
    private String to;
    private String priority;

    // private constructor
    private RouteTuple(String from, String to, String priority) {
        this.from = from;
        this.to = to;
        this.priority = priority;
    }

    /**
     * Get origin
     * @return from
     */
    public String getFrom() {
        return from;
    }

    /**
     * Get destination
     * @return to
     */
    public String getTo() {
        return to;
    }

    /**
     * Get priority
     * @return priority
     */
    public String getPriority() {
        return priority;
    }

    /**
     * Factory method to create a route tuple
     * @param from
     * @param to
     * @param priority
     * @return routeTuple
     */
    public static RouteTuple create(String from, String to, String priority) {
        return new RouteTuple(from, to, priority);
    }

    /**
     * Two RouteTuples are equal if they have the same from.to and priority
     *
     * @param o
     * @return boolean
     */
    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof RouteTuple)) {
            return false;
        } else {
            RouteTuple route = (RouteTuple) o;
            return (route.getFrom().equals(this.getFrom()) && route.getTo().equals(this.getTo()) && route.getPriority().equals(this.getPriority()));
        }
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 83 * hash + (this.from != null ? this.from.hashCode() : 0);
        hash = 83 * hash + (this.to != null ? this.to.hashCode() : 0);
        hash = 83 * hash + (this.priority != null ? this.priority.hashCode() : 0);
        return hash;
    }
}
